package com.gjzhao.fmmall.controller;

import cn.hutool.core.util.RandomUtil;
import com.gjzhao.fmmall.vo.RespResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 模拟死锁情况，进行生产环境服务器变慢排查
 * @Author: gjzhao
 * @Date Created in 2022-03-03 10:23 下午
 */
@RestController
@CrossOrigin
@Api(value = "模拟测试管理",tags = "死锁模拟")
public class DeadLockController extends BaseController {

    @GetMapping("/testDeadLock")
    @ApiOperation(value = "模拟死锁场景")
    @ApiImplicitParam(value = "死锁开启按钮", name = "lock", dataType = "boolean", required = true)
    public RespResultVO testDeadLock(@RequestParam("lock") boolean lock) {


        while (lock) {
            logger.info("---输出随机数:{}---", RandomUtil.randomInt());
        }

        return RespResultVO.success("成功");
    }
}
